<template>
	<view>
		<view v-if="pageLoading" style="padding-top: 44px;">
			<ant-skeleton />
		</view>
		<template v-else>
			<diy-template :scrollTop="scrollTop" ref="diy" :bottomNavigation="false">
			</diy-template>
		</template>
	</view>
</template>
<script>
	var app = getApp().globalData
	import diyTemplate from "./components/diy_template/diy_template.vue";
	export default {
		components: {
			diyTemplate
		},
		data() {
			return {
				page_id: 0, // 页面id
				pageLoading: false, // 页面加载loading
			}
		},
		async onLoad(e) {
			await this.$onLaunched;
			// #ifdef MP-WEIXIN
			uni.showShareMenu({
				menus: ['shareAppMessage', 'shareTimeline']
			});
			// #endif
			this.page_id = e.page_id;
			this.getPageData(e.page_id);
			
			
		},
		onPageScroll(e) {
			// 传入scrollTop值并触发所有easy-loadimage组件下的滚动监听事件
			this.scrollTop = e.scrollTop;
		},
		
		methods: {
			// 获取商户页面
			getPageData(page_id) {
				return new Promise(async resolve => {
					try {
						const {
							status,
							data,
							message,
						} = await this.$request('DiyStore/Api/getMerchantPageData', {
							needErrorMsg: false,
							page_id:page_id
						});
						if (status == 1) {
							this.page_content = data.content;
							this.$nextTick(() => {	
								this.$refs["diy"] && this.$refs["diy"].onShows();
							})
							this.$nextTick(() => {
								resolve(true);
							})
						} else {
							resolve(false);
						}
					} catch (err) {
						resolve(false);
					}
				});
			}
		}
		
	}
</script>
